var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if(isiOS) {
	console.log("ios")
}

//加载图片
var loader = new resLoader({
	resources: [
		'img/success.png',
		'img/wubg.png',
		'img/left.gif',
		'img/conzhong.gif',
		'img/right.gif',
		'img/_99.png',
		'img/1.png',
		'img/2.png',
		'img/3.png',
		'img/4.png',
		'img/5.png',
		'img/6.png',
		'img/7.png',
		'img/bg_img.jpg',
		'img/bg_shart.png',
		'img/bth_look.png',
		'img/bth_look.png',
		'img/conzhong.gif',
		'img/f00.png',
		'img/f02.png',
		'img/f05.png',
		'img/f1.png',
		'img/f2.png',
		'img/f3.png',
		'img/go.png',
		'img/huaping.png',
		'img/jishu_.png',
		'video/tao.mp4',
		'img/jishu_0.png',
		'img/jishu_1.png',
		'img/jishu_2.png',
		'img/juan.png',
		'img/juan2.png',
		'img/left1.png',
		'img/mupai1.png',
		'img/mupai2.png',
		'img/mupai3.png',
		'img/qiehuan.gif',
		'img/renou.png',
		'img/righ1.png',
		'img/s-bg.png',
		'img/s-bg.png',
		'radio/beizi.mp3',
		'radio/changjingradio.mp3',
		'radio/jiazai.mp3',
		'radio/kaimensheng.mp3',
		'radio/kaimensheng.mp3',
		'radio/mupai.mp3',
		'radio/renou.mp3',
		'radio/weiyefenxiang.mp3',
		'radio/zhizhang.mp3'
	],
	onStart: function(total) {},
	onProgress: function(current, total) {
		var percent = Math.floor(current / total * 100);
		$('.loadings .loadTxt').text(percent + "%");
		$('.layers .layer-son').css('width', (100 - percent) + "%")
	},
	onComplete: function(total) {
		setTimeout(() => {
			$('.loadings').css('display', 'none');
			$('.btm_content').css('display', 'none')
			$('.what').css('display', 'block')
		}, 100)
	}
});
//
loader.start();

//screen.orientation.lock('landscape');

//function createMarker(x, y) {
//	var div = document.createElement('div');
//	div.className = 'marker';
//	div.style.left = x + 'px';
//	div.style.top = y + 'px';
//	document.getElementById('dv').appendChild(div)
//}
//document.getElementById('dv').onclick = function(e) {
//	e = e || window.event;
//	var x = e.offsetX || e.layerX,
//		y = e.offsetY || e.layerY;
//	createMarker(x, y);
//}

//强制手机横屏
const width = document.documentElement.clientWidth;
const height = document.documentElement.clientHeight;
if(width < height) {
	console.log(width + " " + height);
	const contentDOM = document.getElementById('index_web');
	contentDOM.style.width = height + 'px';
	contentDOM.style.height = width + 'px';
	contentDOM.style.top = (height - width) / 2 + 'px';
	contentDOM.style.left = 0 - (height - width) / 2 + 'px';
	contentDOM.style.transform = 'rotate(90deg)';
}

//文字循环
var cons = $('.loading .con');
var i = 0;
setInterval(function() {
	if(i < cons.length) {
		$('.loading .btm_content').find('.con').eq(i).addClass('block').siblings().removeClass('block');
		i++;
	} else if(i == cons.length) {
		i = 0;
		$('.loading .btm_content').find('.con').addClass('hidden');
	}
}, 2000)

//点击发生了什么 进去视频播放;

function bofang(){
	var bgmusic = document.querySelector(".audios");

	function audioAutoPlay(id) {
		bgmusic.play();
		document.addEventListener("WeixinJSBridgeReady", function() {
			bgmusic.play();
		}, false);
		document.addEventListener('YixinJSBridgeReady', function() {
			bgmusic.play();
		}, false);
	}
	audioAutoPlay('bgmusic');
}


$('.what').on('touchstart', function() {
	$(this).css('display', 'none')
	$('.loading').css('display', 'none')
	$('.video_').css('display', 'block');
	h5vid.play()
	setTimeout(function() {
		$('.go').css('opacity', '1')
	}, 1000)
	var time_s = setTimeout(function() {
		jin_an();
		bofang();
	}, 18000);
	// setTimeout(function(){
	// 	clearTimeout(time_s)
	// 	vase_audio.volume = 0;
	// },22000)
	//背景音乐
// index_audio.autoplay = true;
// index_audio.loop = true;

})

//点击进入案发现场
var vase_audio = new Audio()
vase_audio.src = 'radio/kaimensheng.mp3';
$('.go').one('click', function() {
		jin_an();
		bofang();
		setTimeout(function() {
			$('.go').css('opacity', '1')
		}, 1000)
		vase_audio.volume = 0;
	})

function jin_an(){
	var time = 1;
	$('.what').css('display', 'none')
	$('.loading').css('display', 'none')
	$(this).parent().css('transform', 'scale(0)')
	setTimeout(function(){
		$('.switch_').css('display', 'block');
		vase_audio.play();
	},1000)
	$('.video_').remove();
	$('video').remove();
	$('.video_').empty();
	var go_time = setInterval(function() {
		time = time - 0.1;
		if(time <= 0) {
			clearInterval(go_time);
			$('.switch_').css('display', 'none');
			$('.content').css('display', 'block')
		}
		console.log(time)
		$('.switch_').css('opacity', time);
	}, 300)
	$('.count').css('display', 'block')
}


//	}


//点击花瓶
$('.content .vase').one('click', function() {
	$(this).addClass('vase_fallen');
	var vase_audios = new Audio()
	vase_audios.src = 'radio/beizi.mp3';
	vase_audios.play();
})

//点击线索用券1
var num_time = 0
$('.securities').one('click', function() {
	num_time++;
	console.log(num_time + "55")
	$(this).css('display', 'none')
	var securities_audio = new Audio()
	securities_audio.src = 'radio/zhizhang.mp3';
	securities_audio.play();
	if(num_time == 1) {
		$('.num .nun_son').attr('src', 'img/jishu_1.png');
		$('.securities_div').addClass('securities_scale')
	}
	if(num_time == 2) {
		$('.num .nun_son').attr('src', 'img/jishu_2.png');
		$('.success').addClass('success_scale')
	}
});
$('.securities_div').one('click', function() {
	$(this).removeClass('securities_scale');
})

//点击线索用券2
$('.securities2').one('click', function() {
	num_time++;
	console.log(num_time + "666")
	$(this).css('display', 'none')
	var securities_audio = new Audio()
	securities_audio.src = 'radio/zhizhang.mp3';
	securities_audio.play();
	$('.content').css('-webkit-overflow-scrolling', 'auto')
	if(num_time == 1) {
		$('.num .nun_son').attr('src', 'img/jishu_1.png');
		$('.securities2_div').addClass('securities_scale');
	}
	if(num_time == 2) {
		$('.num .nun_son').attr('src', 'img/jishu_2.png');
		$('.success').addClass('success_scale')
	}
})
$('.securities2_div').one('click', function() {
	$(this).removeClass('securities_scale');
	$('.content').css('-webkit-overflow-scrolling', 'touch')
})

//点击人偶
$('.doll').one('click', function() {
	$(this).addClass('doll_animetd')
	var doll_audio = new Audio()
	doll_audio.src = 'radio/renou.mp3';
	doll_audio.play();
})

//点击木牌
$('.mupai').on('click', function() {
	$(this).addClass('mupai_rotate');
	var mupai_audio = new Audio()
	mupai_audio.src = 'radio/mupai.mp3';
	mupai_audio.play();
})

//点击查看
$('.Bth').on('click', function() {
	$(this).parent().css('transform', 'scale(0)');
	$('.share').addClass('active')
	var share_audio = new Audio();
	share_audio.loop = true;
	share_audio.src = 'radio/weiyefenxiang.mp3';
	share_audio.play();
	index_audio.pause();
})
$('.share_bth').on('click',function(){
	$('.jiantou').css('display','block')
})
//Content();